package com.wawei.seeds.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.wawei.seeds.R;
import com.wawei.seeds.model.WalnutMainEvent;

import butterknife.ButterKnife;
import butterknife.InjectView;


/**
 * Created by R308665 on 2015/6/22.
 */
public class MeFavoriteFragmentAdapter extends SeedsBaseAdapter<WalnutMainEvent>{

        public MeFavoriteFragmentAdapter(Context context){
            super(context);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = convertView;
            ViewHolder viewHolder;
            if(null == view){
                view = LayoutInflater.from(context).inflate(R.layout.fragment_walnut_me_favorite_item, parent, false);
                viewHolder = new ViewHolder(view);
                view.setTag(viewHolder);
            }
            else {
                viewHolder = (ViewHolder)view.getTag();
            }
            WalnutMainEvent item = (WalnutMainEvent)getItem(position);
            viewHolder.eventName.setText(item.title);
            viewHolder.eventAction.setText(item.action);
            viewHolder.eventAvailable.setText(item.available);
            imageLoader.loadImage(item.publisherHeadPortrait, viewHolder.heroLogo, true, false);

            return view;
        }

        static class ViewHolder{
            @InjectView(R.id.item_favorite_hero_logo)ImageView heroLogo;
            @InjectView(R.id.item_favorite_event_action )TextView eventAction;
            @InjectView(R.id.item_favorite_event_name )TextView eventName;
            @InjectView(R.id.item_favorite_event_available)TextView eventAvailable;

            public ViewHolder(View view) {
                ButterKnife.inject(this, view);
            }
        }
    }

